<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>My JSP 'MyJsp.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
  </head>
  
  <body>
    
    		
    		 <button type="button" id="photoBtn" class="layui-btn layui-btn-normal">更换头像</button>
                    	<div class="layui-upload-list">
						    <img width="118"  height="118" class="layui-upload-img" id="demo1">
						     <br><br><button type="button" id="uploadBtn"  class="layui-btn layui-btn-normal">确定上传</button>	
						 </div>
    		
    		
    		
   
   <script src="statics/plugs/layui/layui.js"></script>
   <script type="text/javascript">
   layui.use(['layer', 'form','element','laypage','jquery','layedit','upload'], function(){
   		  var layer = layui.layer,$=layui.jquery
        ,form = layui.form;
    var element = layui.element;
    var laypage = layui.laypage;
    var layedit = layui.layedit;
    var  upload=layui.upload;
	    //执行实例
	    var uploadInst = upload.render({
	      elem: '#photoBtn' //绑定元素
	      ,url: $("#path").val()+'/uploadPhoto' //上传接口
	       ,accept:'images'
	       ,acceptMime:'image/*'
	       ,field:'upload'
	       ,auto:false
	       ,bindAction:'#uploadBtn'
	      ,choose: function(obj){
	    	      //预读本地文件示例，不支持ie8
	    	 obj.preview(function(index, file, result){
	    		 $('#demo1').attr('src', result); //图片链接（base64）
	    	 });
	      }
	      ,done: function(res){
	        //上传完毕回调
	      }
	      ,error: function(){
	        //请求异常回调
	    	  layer.msg("错误啦")
	      }
	    });
	  
	  }); 
   </script>
    		
  </body>
</html>
